//package com.zjmy.component;
//
//import com.lgCore.factory.RpcServiceZkFactory;
//import com.lgCore.server.RpcServer;
//import com.lgCore.server.factory.CommonRpcServiceFactory;
//import com.lgCore.server.model.ServiceZkData;
//import com.lgCore.server.service.CommonRpcServerService;
//import com.lgCore.util.ClassUtil;
//import com.lgCore.util.IpAddr;
//
//import java.util.ArrayList;
//import java.util.List;
//import java.util.Set;
//
//public class SxRpcTcpServer implements RpcServer {
//
//    private String zkRegistry;
//    private String servicePack;
//    private int sessionTimeOut;
//    public SxRpcTcpServer(String zkRegistry, String servicePack,int sessionTimeOut) {
//        this.zkRegistry = zkRegistry;
//        this.servicePack = servicePack;
//        this.sessionTimeOut =sessionTimeOut;
//    }
//
//    @Override
//    public void stop() throws Exception {
//        //关闭netty
//        CommonRpcServiceFactory.getServerBootStrap().getBoss().shutdownGracefully();
//        CommonRpcServiceFactory.getServerBootStrap().getWorker().shutdownGracefully();
//    }
//
//    @Override
//    public void start() throws Exception {
//        //初始化service类到zk
//        RpcServiceZkFactory.getCommonServiceServer().connectZookeeper(zkRegistry, sessionTimeOut);
//        //注入service 到zk
//        Set<Class<?>> classSet = ClassUtil.getIntegerClass(servicePack);
//        List<ServiceZkData> serviceZkDataList = new ArrayList<ServiceZkData>();
//        if (classSet != null && classSet.size() > 0) {
//            for (Class<?> t : classSet) {
//                ServiceZkData serviceZkData = new ServiceZkData();
//                serviceZkData.setIp(IpAddr.getIpAddr());
//                serviceZkData.setNettyPort(CommonRpcServiceFactory.getServerBootStrap().getPort());
//                serviceZkData.setServicePath(t.getName());
//                serviceZkDataList.add(serviceZkData);
//            }
//        }
//
//        RpcServiceZkFactory.setServiceZkDataList(serviceZkDataList);
//        CommonRpcServerService.getInstance().registerService(RpcServiceZkFactory.getServiceZkDataList());
//        //初始化service方法到内存
//        CommonRpcServiceFactory.getCommonRpcRouteService().initServiceMethod(MySpringContext.getApplicationContext(), servicePack);
//
//    }
//}
